clear all

use ../Data/Clean/cleaned_recruiter_data.dta, clear


merge m:1 ciphertext using ../Data/Raw/more-covars.dta
keep if _merge==3
drop _merge

merge m:1 screenerid using ../Data/Raw/2SA-age-exp

gen yfb=totalfeedbacks >0
gen yca=nocurassignments==0
gen yr=norevenue==0
gen ypt=totalpassedtests>0
gen yahb=totalactualhoursbilled>0
gen p1=pacceptinterview
gen p2=ppassinterview
gen p3=pacceptjoboffer
gen fullybilled=totalhours2>=2
gen logp1=log(p1)
gen logp2=log(p2)
gen logp3=log(p3)
gen incum_index=yfb+yca+yr+ypt+yahb+fullybilled
egen incum_index_std=std(incum_index)

gen cey=collegeentryyear

foreach var in yfb yca yr ypt yahb fullybilled incum_index incum_index_std abovemedianage abovemedexp cey {
	foreach var2 in p1 p2 p3 logp1 logp2 logp3 {
		gen `var'_`var2'=`var'*`var2'
	}
}

label variable interview "Interview"
label variable yfb "\makecell{Has\ \Reviews}"
label variable yca "\makecell{Has\ \Other\ \Assign-\ \ments}"
label variable yahb "\makecell{Previously\ \Billed\ \Hours}"
label variable yr "\makecell{Has\ \Prior\ \Revenue}"
label variable ypt "\makecell{Has\ \Certif-\ \ications}"
label variable fullybilled "\makecell{Fully-\ \billed}"
label variable incum_index_std "Index($\sigma$)"
gen expp1=.
gen expp2=.
gen expp3=.
gen exp_logp1=.
gen exp_logp2=.
gen exp_logp3=.

label variable p1 "P(Accept Interview)"
label variable p2 "P(Accept Pass Interview)"
label variable p3 "P(Accept Job)"

label variable expp1 "P(Accept Interview)$\times$ Characteristic"
label variable expp2 "P(Accept Pass Interview)$\times$ Characteristic"
label variable expp3 "P(Accept Job)$\times$ Characteristic"
label variable exp_logp1 "P(Accept Interview), Log $\times$ Characteristic"
label variable exp_logp2 "P(Accept Pass Interview), Log $\times$ Characteristic"
label variable exp_logp3 "P(Accept Job), Log $\times$ Characteristic"


***********************************************
***** Table B10: RECRUITER INCUMBENCY    ******
***********************************************


foreach var in yfb yca yr ypt yahb fullybilled incum_index incum_index_std abovemedianage abovemedexp {
	*disp "`var'"
	forvalues i = 1/3 {
		replace expp`i'=`var'_p`i'
		replace exp_logp`i'=`var'_logp`i'
	}
	reg interview p1 p2 p3 `var' expp1 expp2 expp3, cluster(screenerid) 
	local x: variable label `var'
	estadd local ExpMeasure "`x'"
	eststo `var'
	logit interview logp1 logp2 logp3 `var' exp_logp1 exp_logp2 exp_logp3, cluster(screenerid) 
	estadd scalar r2 = e(r2_p)
	local x: variable label `var'
	estadd local ExpMeasure "`x'"
	eststo `var'_l
}
global myopts "bf(%15.2gc) sfmt(%15.2gc) prehead(\begin{tabular}{l*{14}{c}}) postfoot(\end{tabular}) se label noisily noeqlines nonumbers varlabels(_cons Constant, end("" ) nolast)  starlevels(* 0.1 ** 0.05 *** 0.01) replace"


esttab incum_index_std_l yfb_l yca_l yr_l ypt_l yahb_l fullybilled_l using ../Output/Tables/Appendix/TableB10_A.tex, $myopts keep( logp1 logp2 logp3 exp_logp1 exp_logp2 exp_logp3) stats(r2 N ExpMeasure, label("\(R^{2}\)" "Observations" "\hline Recruiter Characteristic" )) substitute("\ \" \\) gaps eqlabels(none)
esttab incum_index_std yfb yca yr ypt yahb fullybilled using ../Output/Tables/Appendix/TableB10_B.tex, $myopts keep(p1 p2 p3 expp1 expp2 expp3) stats(r2 N ExpMeasure, label("\(R^{2}\)" "Observations" "\hline Recruiter Characteristic" )) substitute("\ \" \\) gaps 


***********************************************
***** Table B11: RECRUITER INCUMBENCY W/ AGE    ******
**********************************************

foreach var in yfb yca yr ypt yahb fullybilled incum_index incum_index_std {
	forvalues i = 1/3 {
		replace expp`i'=`var'_p`i'
		replace exp_logp`i'=`var'_logp`i'
	}
	pdslasso interview p1 p2 p3 expp1 expp2 expp3 (  `var' abovemedianage abovemedianage_p1 abovemedianage_p2 abovemedianage_p3 abovemedexp abovemedexp_p1 abovemedexp_p2 abovemedexp_p3), cluster(screenerid )
	local x: variable label `var'
	estadd local ExpMeasure "`x'"
	eststo `var'
}

global myopts "bf(%15.2gc) sfmt(%15.2gc) prehead(\begin{tabular}{l*{14}{c}}) postfoot(\end{tabular}) se label noisily noeqlines nonumbers varlabels(_cons Constant, end("" ) nolast)  starlevels(* 0.1 ** 0.05 *** 0.01) replace"
esttab incum_index_std yfb yca yr ypt yahb fullybilled using ../Output/Tables/Appendix/TableB11.tex, $myopts keep(expp1 expp2 expp3) stats(r2 N ExpMeasure, label("\(R^{2}\)" "Observations" "\hline Recruiter Characteristic" )) substitute("\ \" \\) gaps 
